<template>
  <div class="viewcart">
    <div class="moder">
      <div class="flex1 top">
        <div class="topline">
          <img src="/static/images/qixingzonglicheng.png" class="img1"/>
          <div class="right-text">
            <text class="tx1">{{energySaving.totalTravelMileage}} km</text>
            <text class="tx2">骑行总里程</text>
          </div>
        </div>
        <div class="topline">
          <img src="/static/images/jieyuetanpaifang.png" class="img2"/>
          <div class="right-text">
            <text class="tx1">{{energySaving.carbonEmissions}} kg</text>
            <text class="tx2">节约碳排放量</text>
          </div>
        </div>
      </div>
      <div v-if="List && List.length!==0">
        <div class="list" v-for="(item,index) in List" :key="index">
          <text class="date">
            <text class="d1">{{item.createTime}}</text>
            <text class="d2">({{item.week}})</text>
          </text>
          <div class="dt">
            <div class="flex1 time">
              <text class="lis01">{{item.tripStr}}</text>
              <text class="lis02">{{item.orderAmount}}元</text>
            </div>
          </div>
        </div>
      </div>
      <div class="no-path" v-else>
        <img src="/static/images/no_path.png" alt="">
        <div class="no-path-text">暂无骑行</div>
      </div>
    </div>
    <!-- <footer>
      <text class="footer1">小程序暂不支持查看详情，请前往考拉出行app查看！</text>
    </footer> -->


  </div>
</template>

<script>
  import Service from '@/utils/service'

  export default {
    data() {
      return {
        isPass: true,
        pageHeight: null,
        List: [],
        page: 1,
        energySaving: {
          totalTravelMileage: '',
          carbonEmissions: ''
        }
      }
    },
    onLoad() {
      let userInfo = wx.getStorageSync('userInfo')
      if (!userInfo) {
        wx.redirectTo({
          url: '../login/main'
        })
        return
      }
      this.pageHeight = wx.getSystemInfoSync().windowHeight - 90
      this.List = []
      this.page=1
      this.getList(1)
    },
    onReachBottom() {
      this.getList(this.page)
    },
    methods: {
      getList(page) {
        const params = {pageNum: page, pageSize: 10}
        const that = this
        Service.gettrips(params)
          .then((res) => {
            if (res.code == 200) {
              this.energySaving = res.data.energySaving
              if (res.data.trips.length > 0) {
                var arr = this.List
                for (var i = 0; i < res.data.trips.length; i++) {
                  arr.push(res.data.trips[i])
                }
                this.List = arr
                if (res.data.trips.length > 0) {
                  this.page++;
                }

              }
            }
          })
      },
    }
  }
</script>

<style scoped>
  .topline{
    padding: 30px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 48%;
    border-radius: 5px;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
  }
  .img1 {
    float: left;
    width: 120px;
    height: 120px;
  }

  .img2 {
    float: left;
    width: 120px;
    height: 120px;
  }
  
  .no-path {
    margin-top: 150px;
    text-align: center;
  }
  .no-path>img {
    width: 200px;
    height: 155px;
  }
  .no-path-text {
    margin-top: 10px;
    font-size: 24rpx;
    color: #999;
  }

  .flex1 {
    justify-content: space-between;
  }
  .right-text {
    text-align: left;
  }

  .tx1 {
    display: block;
    font-size: 32px;
    font-weight: 500;
    color: #523A24;
    line-height: 30px;
    /* display: inline-block; */
  }

  .tx2 {
    font-size: 24px;
    color: #999;
    margin-top: 20px
  }

  .left {
    width: 2px;
    height: 79px;
    background: rgba(238, 238, 238, 1);
  }

  .top {
    padding: 0 3%;
    height: 178px;
    margin: 10px auto 50px;
    text-align: center;
  }

  .lis01 {
    color: #999;
    font-size: 30px;
  }

  .lis02 {
    color: #999;
    font-size: 30px;
  }

  .lis03 {
    color: #333;
    font-size: 26px;
  }

  .lis04 {
    color: #999;
    font-size: 28px;
    display: block;
    width: 100px;
    text-align: right
  }

  .lis04.red {
    color: #FF3939;
    font-size: 28px;
  }

  .dt {
    margin: 0 30px 0 30px;
    padding-right: 25px;
    /*border-bottom: 2px solid #DDDDDD;*/
  }

  .time {
    margin: 0 0 40px;
  }

  .address {
    align-items: flex-end;
    position: relative;
  }

  .quan1:before, .quan2:before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 4px solid #E73828;
    border-radius: 100%;
    position: relative;
    margin-left: 0px;
    margin-right: 20px;
    top: 0
  }

  .quan2:before {
    border: 4px solid #64b9f5;
  }

  .jindu {
    border-left: 4px solid #ccc;
    position: absolute;
    left: 8px;
    top: 29px;
    bottom: 29px;

  }

  .lis03 {
    display: flex;
    align-items: flex-start;
  }

  .quan1text, .quan2text {
    display: inline-block;
    width: 550px;
  }

  /*.quan1{*/
  /*border-left: 1px solid #2C9D23;*/
  /*}*/
  .line {
    margin-top: 38px;
  }

  .moder {
    padding-bottom: 80px
  }

  footer {
    width: 750px;
    height: 80px;
    line-height: 80px;
    background: rgba(242, 242, 242, 1);
    position: fixed;
    bottom: 0;
    left: 0;
    text-align: center;
  }

  .footer1 {
    color: #666;
    font-size: 26px;
  }

  .list {
    border-bottom: 1px solid #ddd;
  }
  .list:last-of-type {
    border: none;
  }

  .date {
    display: block;
    padding-left: 30px;
    margin: 30px 0 20px;
    font-weight: 500;
  }

  .d1 {
    font-size: 28px;
    line-height: 40px;
    color: rgba(51, 51, 51, 1);
  }

  .d2 {
    padding-left: 20px;
    font-size: 28px;
    line-height: 50px;
    color: rgba(51, 51, 51, 1);

  }

  .line2 {
    width: 750px;
    height: 40px;
    background: rgba(242, 242, 242, 1);
  }


</style>
